package com.xjc.business.controller.colladmin;

import com.xjc.business.entity.vo.PageVo;
import com.xjc.business.entity.vo.coladmin.StuVo;
import com.xjc.business.service.StudentsService;
import com.xjc.system.constants.MyConstants;
import com.xjc.system.exception.MyException;
import com.xjc.system.result.Result;
import com.xjc.system.result.ResultCode;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 徐锦程
 * 时间:2025-01-30 8:57
 */
@RestController
@RequestMapping("/college_admin/stu")
public class StuController {

    @Autowired
    StudentsService studentsService;

    /**
     * 分页查询学生信息
     * @param pageSize 每页数量
     * @param currentPage 当前页码
     * @param collegeId 院校id
     * @param majorId 专业id
     * @param classId 班级id
     * @return 数据
     */
    @RequestMapping("/page/{pageSize}/{currentPage}")
    public Result<PageVo<StuVo>> getStuPage(
            @PathVariable(value = "pageSize",required = false) Integer pageSize,
            @PathVariable(value = "currentPage",required = false) Integer currentPage,
            Integer collegeId,
            Integer majorId,
            Integer classId
            ){
        if (pageSize == null || pageSize <= 0){
            pageSize = 10;
        }
        if (currentPage == null || currentPage <= 0){
            currentPage = 1;
        }

        if (collegeId == null || majorId==null || classId == null){
            throw new MyException(ResultCode.SUCCESS.getCode(), MyConstants.PARAM_MISSING);
        }

        return studentsService.getStuPage(pageSize,currentPage,collegeId,majorId,classId);
    }
}
